package com.demo.study.behavior.d01_chainOfResponsibility.base;

import com.demo.study.behavior.d01_chainOfResponsibility.base.filter.NameFilter;
import com.demo.study.behavior.d01_chainOfResponsibility.base.filter.PlaceFilter;
import com.demo.study.behavior.d01_chainOfResponsibility.base.filter.SensitiveFilter;

/**
 * chainOfResponsibility 责任链模式
 *
 * @author Baymax
 * @since 2021/1/17
 */
public class Main {
    public static void main(String[] args) {
        Msg msg = new Msg("Hello :) <name>, welcome to <place>, here is 996!");
        msg.setName("张三");
        msg.setPlace("China NJ");

        FilterChain fc1 = new FilterChain();
        fc1.add(new NameFilter())
                .add(new PlaceFilter());

        FilterChain fc2 = new FilterChain();
        fc2.add(new SensitiveFilter());
        fc1.add(fc2);

        fc1.doFilter(msg);

        System.out.println(msg.getMsg());
    }
}
